<template>
	<view class="newsDetailsList">
		<view class="list flex-r-b-c" v-for="(item,index) in newsList" :key="index">
			<image src="/static/logo.png" mode="widthFix"></image>
			<view class="list_r">
				<view class="list_r_t flex-r-b-c">
					<view class="name">氧发堂</view>
					<view class="time">{{item.createdate}}</view>
				</view>
				<view class="list_r_b">{{item.content}}</view>
			</view>
		</view>
		
		<view class="text" style="width: 100%; text-align: center; font-size: 32rpx; font-weight: bold;">{{titleText}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				newsList: [], // 消息详情列表
				pageData: {}, // 上一页传参数据
				page: 1, // 页码
				titleText: '', // 上拉提示
			};
		},
		onLoad(el) {
			this.pageData = el
			this.modifyNewsRead()  // 修改消息已读
			this.getNewsDetailsList()  // 获取消息详情列表
		},
		onReachBottom() {
			let that = this
			if(that.titleText == ''){ // 防止上拉多次请求
				that.page = that.page+1
				that.getNewsDetailsList()
			}
		},
		methods:{
			// 获取消息详情列表
			getNewsDetailsList(){
				let that = this
				that.$api.newsDetails_list({id: that.pageData.id, page: that.page}).then(res => {
					that.titleText = res.data.data.data.length == 0 ? '暂无数据' : ''
					that.newsList = that.newsList.concat(res.data.data.data)
				})
			},
			
			// 修改消息已读
			modifyNewsRead(){
				let that = this
				that.$api.newsRead({cid: that.pageData.id}).then(res => {
				})
			},
		}
	}
</script>

<style lang="less">
	page{
		background-color: #FFFFFF;
	}
	.newsDetailsList{
		width: 100vw;
		height: auto;
		box-sizing: border-box;
		padding: 40rpx;
		.list{
			width: 100%;
			height: 160rpx;
			border-bottom: 1px solid #F5F5F5;
			image{
				width: 80rpx;
				height: 80rpx;
			}
			.list_r{
				width: 84%;
				.name{
					font-size: 38rpx;
					font-weight: bold;
				}
				.time{
					font-size: 28rpx;
					color: #999999;
				}
			}
		}
	}
</style>
